package com.xxx.controller;


import com.xxx.common.Result;
import com.xxx.dto.IndentDto;
import com.xxx.feignclient.OrderClient;
import com.xxx.util.ThreadLocalUntil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/indent")
@Slf4j
public class IndentController {

    @Autowired
    private OrderClient orderClient;

    @PostMapping("/save")
    public Result saveIndent(@RequestBody IndentDto indentDto){
        log.info("indentDto:{}",indentDto);

        indentDto.setStatus(2);
        indentDto.setOrderUser(ThreadLocalUntil.getCurrentId());
        indentDto.setPayDateTime(LocalDateTime.now());

        Result result = orderClient.saveIndent(indentDto);

        return result;
    }

    @GetMapping("/list")
    public  Result getOrderList(){

        Result orderList = orderClient.getOrderList(ThreadLocalUntil.getCurrentId());
        return orderList;
    }

}
